package com.youmingxing.network;

import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class AccountApi {

    public static void getRegisterCode(String number, JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("mobile", number);
        HttpManager.client.post(HttpManager.BASE_URL + "sms/down.json", params, handler);
    }

    public static void verifyCode(String number, String code, int verifyType, JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("mobile", number);
        params.put("code", code);
        params.put("type",verifyType);
        HttpManager.client.post(HttpManager.BASE_URL + "sms/up.json", params, handler);
    }

    public static void login(String number, String password, JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("mobile", number);
        params.put("passphrase", password);
        HttpManager.client.post(HttpManager.BASE_URL + "mobilelogin.action", params, handler);
    }

    public static void register(String number, String password, String code, JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("mobile", number);
        params.put("code", code);
        params.put("passphrase", password);
        HttpManager.client.post(HttpManager.BASE_URL + "mobilereg.action", params, handler);
    }

    public static void completInfo(String nickname, String headimg, int gender, JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("nickname", nickname);
        params.put("headimg", headimg);
        params.put("gender", gender);
        HttpManager.client.post(HttpManager.BASE_URL + "file_loginInfo.action", params, handler);
    }


    //获取账号绑定信息
    public static void getbindInfo(JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        HttpManager.client.post(HttpManager.BASE_URL + "bindlogin_info.json", params, handler);
    }

    //账号绑定其他第三方账号
    public static void bindOtherAccount(String provider, String uid, String passphrase, JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("provider", provider);
        params.put("uid", uid);
        if (passphrase != "" && passphrase != null) {
            params.put("passphrase", passphrase);
        }
        HttpManager.client.post(HttpManager.BASE_URL + "bindlogin.action", params, handler);
    }

    //第三方登陆
    public static void loginByOuth(String id, String nickname, String headimg,String provider, JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("provider", provider);
        params.put("id", id);
        params.put("nickname", nickname);
        params.put("headimg", headimg);
        HttpManager.client.post(HttpManager.BASE_URL + "openlogin.action", params, handler);
    }

    //修改密码
    public static void modifyPassword(String mobile, String passphrase_old, String passphrase_new, JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("mobile", mobile);
        params.put("passphrase_old", passphrase_old);
        params.put("passphrase_new", passphrase_new);
        HttpManager.client.post(HttpManager.BASE_URL + "mobilechangpwd.action", params, handler);
    }

    //忘记密码
    public static void forgetPassword(String mobile, String code, String passphrase_new,
                         JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        params.put("mobile", mobile);
        params.put("code", code);
        params.put("passphrase_new", passphrase_new);
        HttpManager.client.post(HttpManager.BASE_URL + "mobileresetpwd.action", params, handler);
    }

    //腾讯云视频签名
    public static void getVedioSign(JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        HttpManager.client.post(HttpManager.BASE_URL + "cloud/v/sign.json", params, handler);
    }

    //腾讯云图片签名
    public static void getPhotoSign(JsonHttpResponseHandler handler) {
        RequestParams params = HttpManager.getBaseParams();
        HttpManager.client.post(HttpManager.BASE_URL + "cloud/p/sign.json", params, handler);
    }

}